<?php
namespace app\api\controller;



class Configs extends Base
{
    // 定义自动实例化模型
    protected $ModelPath = 'Configs';

    // 是否开启自动验证
    protected $autoValidateCheck = false;

    public function checkUpdateV2()
    {
        $version  = request()->get('version');
        $platform = request()->get('platform');
        if (!$version || !$platform) {
            return showSuccess(['update' => false]);
        }

        $appVersion = $this->M->where('alias', 'APP_LASTED_VERSION')->value('content');
        if ($platform === 'android') {
            if($version != $appVersion)
            {
                $downloadUrl = $this->M->where('alias', 'APP_UPGRADE_LINK_FPR_ANDROID')->value('content');
                return showSuccess([
                    'version' => $appVersion,
                    'update'  => true,
                    'pkgUrl'  => $downloadUrl,
                    'content' => '',
                ]);
            }
        }
        return showSuccess(['update' => false]);
    }
}